da0f90aecbd96ac99cce2e1a42c91f3b2e22bcb9,src/main/java/com/github/games647/lagmonitor/commands/TimingCommand.java,TimingCommand,sendParsedOutput,#Queue#CommandSender#number#,60
Before Change
//nanoseconds -> seconds
float totalSeconds = (float) timing.getTotalTime() / 1000 / 1000 / 1000;
sender.sendMessage(ChatColor.YELLOW + "=== " + category + " Total: " + round(totalSeconds)
+ "sec: " + highlightedPercent + "% " + ChatColor.YELLOW + "===");
if (timing.getSubCategories() != null) {
for (Map.Entry<String, Timing> subEntry : timing.getSubCategories().entrySet()) {
String event = subEntry.getKey().replace("** ", "").replace("-", "");
int lastPackage = event.lastIndexOf('.');
if (lastPackage != -1) {
event = event.substring(lastPackage + 1);
}
Timing subValue = subEntry.getValue();
float avg = (float) subValue.getTotalTime() / subValue.getTotalCount();
float timesPerTick = (float) subValue.getTotalCount() / numTicks;
if (timesPerTick > 1) {
avg *= timesPerTick;
}
float pctTick = avg / 1000 / 1000 / 50 * 100;
// float count = (float) subValue.getTotalCount() / 1000;
//->ms
avg = avg / 1000 / 1000;
float pctTotal = (float) subValue.getTotalTime() / sampleTime * 100;
if (event.equalsIgnoreCase("Full Server Tick")) {
serverLoad = pctTick;
}
sender.sendMessage(ChatColor.DARK_AQUA + event + ' ' + highlightPct(round(pctTotal), 10, 20, 50)
+ " Tick: " + highlightPct(round(pctTick), 3, 15, 40) + " AVG: " + round(avg) + "ms");
}
}
}
sender.sendMessage(ChatColor.YELLOW + "==========================================");
float activatedAvgEntities = (float) activatedEntityTicks / numTicks;
float totalAvgEntities = (float) entityTicks / numTicks;
float averagePlayers = (float) playerTicks / numTicks;
float desiredTicks = (float) sampleTime / 1000 / 1000 / 1000 * 20;
float averageTicks = numTicks / desiredTicks * 20;
String format = ChatColor.DARK_AQUA + "%s" + " " + ChatColor.GRAY + "%s";
//head data
sender.sendMessage(String.format(format, "Avg ticks:", round(averageTicks)));
sender.sendMessage(String.format(format, "Server Load:", round(serverLoad)));
sender.sendMessage(String.format(format, "AVG Players:", round(averagePlayers)));
sender.sendMessage(String.format(format, "Activated Entities:", round(activatedAvgEntities))
+ " / " + round(totalAvgEntities));
sender.sendMessage(String.format(format, "Ticks:", round(numTicks)));
//convert from nanoseconds to seconds
sender.sendMessage(String.format(format, "Sample Time (sec):", round((float) sampleTime / 1000 / 1000 / 1000)));
After Change
//nanoseconds -> seconds
float totalSeconds = (float) timing.getTotalTime() / 1000 / 1000 / 1000;
lines.add(TextComponent.fromLegacyText(ChatColor.YELLOW + "=== " + category
+ " Total: " + round(totalSeconds) + "sec: "
+ highlightedPercent + "% " + ChatColor.YELLOW + "==="));
if (timing.getSubCategories() != null) {
for (Map.Entry<String, Timing> subEntry : timing.getSubCategories().entrySet()) {
String event = subEntry.getKey().replace("** ", "").replace("-", "");
int lastPackage = event.lastIndexOf('.');
if (lastPackage != -1) {
event = event.substring(lastPackage + 1);
}
Timing subValue = subEntry.getValue();
float avg = (float) subValue.getTotalTime() / subValue.getTotalCount();
float timesPerTick = (float) subValue.getTotalCount() / numTicks;
if (timesPerTick > 1) {
avg *= timesPerTick;
}
float pctTick = avg / 1000 / 1000 / 50 * 100;
// float count = (float) subValue.getTotalCount() / 1000;
//->ms
avg = avg / 1000 / 1000;
float pctTotal = (float) subValue.getTotalTime() / sampleTime * 100;
if (event.equalsIgnoreCase("Full Server Tick")) {
serverLoad = pctTick;
}
lines.add(TextComponent.fromLegacyText(ChatColor.DARK_AQUA + event + ' '
+ highlightPct(round(pctTotal), 10, 20, 50)
+ " Tick: " + highlightPct(round(pctTick), 3, 15, 40) + " AVG: " + round(avg) + "ms"));
}
}
}
lines.add(new ComponentBuilder("==========================================").color(ChatColor.GOLD).create());
float activatedAvgEntities = (float) activatedEntityTicks / numTicks;
float totalAvgEntities = (float) entityTicks / numTicks;
float averagePlayers = (float) playerTicks / numTicks;
float desiredTicks = (float) sampleTime / 1000 / 1000 / 1000 * 20;
float averageTicks = numTicks / desiredTicks * 20;
String format = ChatColor.DARK_AQUA + "%s" + " " + ChatColor.GRAY + "%s";
//head data
lines.add(TextComponent.fromLegacyText(String.format(format, "Ticks:", round(numTicks))));
lines.add(TextComponent.fromLegacyText(String.format(format, "Ticks:", round(numTicks))));
lines.add(TextComponent.fromLegacyText(String.format(format, "Avg ticks:", round(averageTicks))));
lines.add(TextComponent.fromLegacyText(String.format(format, "Server Load:", round(serverLoad))));
lines.add(TextComponent.fromLegacyText(String.format(format, "AVG Players:", round(averagePlayers))));
lines.add(TextComponent.fromLegacyText(String.format(format, "Activated Entities:", round(activatedAvgEntities))
+ " / " + round(totalAvgEntities)));
//convert from nanoseconds to seconds
String formatted = String.format(format, "Sample Time (sec):", round((float) sampleTime / 1000 / 1000 / 1000));